//
//  GCMQualityGZRHRequst.m
//  GeeCityManager
//
//  Created by 聚城科技 on 16/8/10.
//  Copyright © 2016年 聚城科技. All rights reserved.
//

#import "GCMQualityGZRHRequst.h"


@implementation GCMQualityGZRHRequst


+ (NSURLSessionDataTask *)postAreaDataWithGLC:(NSString *)glc WithUrl:(NSString*)url Success:(void (^) (id obj , NSError *))success{
    
    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"glc"] = glc;
    
    return [[CZHAppNetAPIClient sharedClient] POST:url parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        
        NSMutableArray *ReciveListArray = [[NSMutableArray alloc]init];
        NSMutableArray *reciveListArray = [[NSMutableArray alloc]init];
        reciveListArray = [dict objectForKey:@"data"];
        for (NSDictionary *dict1 in reciveListArray) {
            NSDictionary *dic = [[NSDictionary alloc]initWithDictionary:dict1];
            [ReciveListArray addObject:dic];
        }
        
        if (success) {
            
            success(ReciveListArray,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];
    
}

+ (NSURLSessionDataTask *)postAreaDataWithAid:(NSString*)aid WithHid:(NSString *)hid WithJiBieid:(NSString *)jibie WithType:type WithPage:(NSString *)page WithData:(NSString *)data WithUrl:(NSString*)url Success:(void (^) (id obj , NSError *))success{
    
    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];

    parameters[@"a_id"] = aid;
    parameters[@"ht_id"] = hid;
    parameters[@"yiji_id"] = jibie;
    parameters[@"page"] = page;
    parameters[@"date"] = data;
    parameters[@"type"] = type;
    NSLog(@"%@",parameters);
    return [[CZHAppNetAPIClient sharedClient] POST:url parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        
        NSMutableArray *ReciveListArray = [[NSMutableArray alloc]init];
        NSMutableArray *reciveListArray = [[NSMutableArray alloc]init];
        NSLog(@"%@",dict);
        reciveListArray = [dict objectForKey:@"data"];
        for (NSDictionary *dict1 in reciveListArray) {
            NSDictionary *dic = [[NSDictionary alloc]initWithDictionary:dict1];
            [ReciveListArray addObject:dic];
        }
        
        if (success) {
            
            success(ReciveListArray,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];
    
}

+ (NSURLSessionDataTask *)postQGZRHDetailDataWithaId:(NSString *)aid WithHtDate:(NSString *)htId WithBianji:(NSString *)jibie Success:(void (^) (id obj , NSError *))success{
    
    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"a_id"] = aid;
    parameters[@"hz_date"] = htId;
    parameters[@"bj_id"] = jibie;
    
    return [[CZHAppNetAPIClient sharedClient] POST:QUALISTDETAIL_URL parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
//        NSLog(@"++1====+  %@",dict);
       
        NSMutableArray *ReciveListArray = [[NSMutableArray alloc]init];
        NSMutableArray *reciveListArray = [[NSMutableArray alloc]init];
        reciveListArray = [dict objectForKey:@"data"];
        for (NSDictionary *dict1 in reciveListArray) {
            [ReciveListArray addObject:[CZHChangeNullString getValueFromDictionary:dict1]];
        }
        if (success) {
            success(ReciveListArray,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];
    
}


@end
